package com.yanqu.road.server.cmd.union.trade;

import com.yanqu.road.pb.union.UnionTradeProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.union.UnionTradeModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

//@Cmd(code = Protocol.S_UNION_TRADE_ROUTE_PATRONS_SEDN, desc = "(加入路线)门客派遣")
public class PatronsSendCmd  extends AbstractCommand {

    private List<Integer> patronsIdList;

    private int routeId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        UnionTradeProto.PatronsSendReqMsg reqMsg = UnionTradeProto.PatronsSendReqMsg.parseFrom(packet.getBytes());
        patronsIdList = reqMsg.getPatronsIdList();
        routeId = reqMsg.getRouteId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(UnionTradeModule.class).joinTradeTeam(routeId, patronsIdList);
        UnionTradeProto.PatronsSendRespMsg.Builder respMsg = UnionTradeProto.PatronsSendRespMsg.newBuilder();
        respMsg.setRet(ret);
        player.sendPacket(Protocol.U_UNION_TRADE_ROUTE_PATRONS_SEDN, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
